<?php

abstract class Soul_Template_Html_Grid_Cell_Base extends Soul_Template_Html_Container {

	private $_grid = NULL;
	private $_text = '';
	private $_emptyText = '';
		
    protected function __construct() {
        $this->addClass('cell');
    }
    
    public function setGrid($value){
    	$this->_grid = $value;
    	return $this;
    }

    public function getGrid() {
        return $this->_grid;
    }

	public function getEmptyText() {
		return $this->_emptyText;
	}
	public function setEmptyText($value) {
		$this->_emptyText = $value;
		return $this;
	}

	public function getText() {
		return $this->_text;
	}
	public function setText($value) {
		$this->_text = $value;
		return $this;
	}

	public function getFormatText() {
		$result = Soul_Util_String::format($this->getText(), $this->getGrid()->getCurrentRow());
		if(is_array($result)){
			$result = implode(',', $result);
		}
		if (is_null($result) || strlen($result) == 0) {
			$result = $this->getEmptyText();
		}
		return $result;
	}
    
    public function renderBegin(){
		return '<td'.$this->getAttributeHtml().'>';    	
    }
    
    public function renderEnd(){
    	return '</td>';
    }
}